package com.yang.mall.controller.admin;


import com.yang.mall.dto.BannerDTO;
import com.yang.mall.entity.Banner;
import com.yang.mall.entity.OLResponse;
import com.yang.mall.entity.QueryRequest;
import com.yang.mall.service.IBannerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 广告表 前端控制器
 * </p>
 *
 * @author kadorlin
 * @since 2022-10-21
 */
@Api(tags = "【PC】轮播图模块")
@RestController
@RequestMapping("admin/banner")
public class BannerAdminController {

    @Resource
    private IBannerService bannerService;

    @ApiOperation("创建广告")
    @PostMapping("/save")
    public OLResponse bannerService(@RequestBody Banner banner){
        bannerService.add(banner);
        return new OLResponse().success();
    }

    @ApiOperation("List通过bannerDTO查询")
    @GetMapping("/getList")
    public OLResponse getListByBannerDTO(BannerDTO bannerDTO){
        return new OLResponse().success(bannerService.getListByBannerDTO(bannerDTO));
    }

    @ApiOperation("Page通过bannerDTO查询")
    @GetMapping("/getPage")
    public OLResponse getPageByCertificationMarksDTO(QueryRequest request, BannerDTO bannerDTO){
        return new OLResponse().success(bannerService.getPageByBannerDTO(request,bannerDTO));
    }

    @ApiOperation("更改广告")
    @PutMapping("/update")
    public OLResponse update(@RequestBody Banner banner){
        bannerService.update(banner);
        return new OLResponse().success();
    }

    @ApiOperation("删除广告")
    @DeleteMapping("/delete")
    public OLResponse delete(@RequestBody BannerDTO bannerDTO){
        bannerService.delete(bannerDTO.getIds());
        return new OLResponse().success();
    }
}
